package com.lyf.system.api.factory;

import com.lyf.common.core.domain.R;
import com.lyf.common.core.web.domain.AjaxResult;
import com.lyf.system.api.RemoteSupermarketService;
import com.lyf.system.api.RemoteUserService;
import com.lyf.system.api.domain.Supermarket;
import com.lyf.system.api.domain.SysUser;
import com.lyf.system.api.model.LoginUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 用户服务降级处理
 * 
 * @author lyf
 */
@Component
public class RemoteSupermarketFallbackFactory implements FallbackFactory<RemoteSupermarketService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteSupermarketFallbackFactory.class);

    @Override
    public RemoteSupermarketService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteSupermarketService()
        {
            @Override
            public R<List<Supermarket>> listAndUser(Supermarket supermarket, String source) {
                return R.fail("获取超市失败:" + throwable.getMessage());
            }

            @Override
            public R<List<Long>> selectSupermarketListByUserId(Long id) {
                return R.fail("获取超市ids失败:" + throwable.getMessage());
            }

            @Override
            public R<Boolean> updateByDay(String source) {
                return R.fail("每日会员积分增加失败:" + throwable.getMessage());
            }

        };
    }
}
